package com.examination.controller.CountModel;

import com.examination.dao.stationModel.StationDao;
import com.examination.entity.Conversion;
import com.examination.service.integralModel.ConversionSService;
import com.examination.service.safetyModel.RiskshowService;
import com.examination.service.staffModel.StaffService;
import com.examination.util.ConversionResult;
import com.examination.util.StatisticsResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(description = "统计数据接口")
@RestController
@RequestMapping("statistics")
@CrossOrigin
public class StatisticsController {
    @Autowired
    private RiskshowService riskshowService;

    @Autowired
    private StaffService staffService;

    @Autowired
    private StationDao stationDao;

    @Autowired
    private ConversionSService conversionSService;

    @ApiOperation(value = "查找积分前三" , notes = "")
    @PostMapping("/find_riskshow_awarda")
    public List<Map> find_riskshow_awarda(@RequestBody Map map) {
        return riskshowService.find_riskshow_awarda(map);
    }

    @ApiOperation(value = "积分奖励" , notes = "")
    @PostMapping("/find_riskshow_award")
    public int find_riskshow_award(@RequestBody Map map) {
        return riskshowService.find_riskshow_award(map);
    }

    @ApiOperation(value = "统计饼图(risk_id)" , notes = "")
    @PostMapping("/find_riskshow_b")
    public List<Map> find_riskshow_b(@RequestBody Map map) {
        return riskshowService.find_riskshow_b(map);
    }

    @ApiOperation(value = "统计饼图 (station_id)" , notes = "")
    @PostMapping("/find_riskshow_c")
    public List<Map> find_riskshow_c(@RequestBody Map map) {
        return riskshowService.find_riskshow_c(map);
    }

    @ApiOperation(value = "返回本月份" , notes = "")
    @PostMapping("/find_month")
    public int find_month() {
        return riskshowService.find_month();
    }

    @ApiOperation(value = "查询当月上旬数据的条数" , notes = "")
    @PostMapping("/find_riskshow_top")
    public int find_riskshow_top(@RequestBody Map map) {
        return riskshowService.find_riskshow_top(map);
    }

    @ApiOperation(value = "查询当月中旬数据的条数" , notes = "")
    @PostMapping("/find_riskshow_mid")
    public int find_riskshow_mid(@RequestBody Map map) {
        return riskshowService.find_riskshow_mid(map);
    }

    @ApiOperation(value = "查询当月下旬数据的条数" , notes = "")
    @PostMapping("/find_riskshow_end")
    public int find_riskshow_end(@RequestBody Map map) {
        return riskshowService.find_riskshow_end(map);
    }

    @ApiOperation(value = "查询当月上旬有效数据的条数" , notes = "")
    @PostMapping("/find_riskshow_top_y")
    public int find_riskshow_top_y(@RequestBody Map map) {
        return riskshowService.find_riskshow_top_y(map);
    }

    @ApiOperation(value = "查询当月中旬有效数据的条数" , notes = "")
    @PostMapping("/find_riskshow_mid_y")
    public int find_riskshow_mid_y(@RequestBody Map map) {
        return riskshowService.find_riskshow_mid_y(map);
    }

    @ApiOperation(value = "查询当月下旬有效数据的条数" , notes = "")
    @PostMapping("/find_riskshow_end_y")
    public int find_riskshow_end_y(@RequestBody Map map) {
        return riskshowService.find_riskshow_end_y(map);
    }

    @ApiOperation(value = "查询当前月上传隐患的条数" , notes = "")
    @PostMapping("/count_riskshow_all")
    public int count_riskshow_all(@RequestBody Map map) {
        return riskshowService.count_riskshow_all(map);
    }

    @ApiOperation(value = "查询当前月审核通过的隐患条数" , notes = "")
    @PostMapping("/count_riskshow_true")
    public int count_riskshow_true(@RequestBody Map map) {
        return riskshowService.count_riskshow_true(map);
    }

    @ApiOperation(value = "统计总人数" , notes = "")
    @PostMapping("/countStaff")
    public int countStaff(@RequestBody Map map) {
        return staffService.countStaff(map);
    }

    @ApiOperation(value = "统计男生人数" , notes = "")
    @PostMapping("/countStaffMan")
    public int countStaffMan(@RequestBody Map map) {
        return staffService.countStaffMan(map);
    }

    @ApiOperation(value = "统计女生人数" , notes = "")
    @PostMapping("/countStaffGirl")
    public int countStaffGirl(@RequestBody Map map) {
        return staffService.countStaffGirl(map);
    }

    @ApiOperation(value = "统计总站点数" , notes = "")
    @PostMapping("/countStation")
    public int countStation(@RequestBody Map map) {
        return stationDao.countStation(map);
    }

    @ApiOperation(value = "查找兑换信息" , notes = "")
    @PostMapping("/select_conversion")
    public List<Conversion> select_conversion(@RequestBody Map map) {
        return conversionSService.selectConversion(map);
    }

    @ApiOperation(value = "个人隐患数据统计" , notes = "")
    @PostMapping("/countRiskshowByStaff")
    public StatisticsResult countRiskshowByStaff(@RequestBody Map map){
        StatisticsResult statisticsResult = new StatisticsResult();
        statisticsResult.setRiskshowAll(riskshowService.countRiskshowByStaffIdAll(map));
        statisticsResult.setRiskshowMonth(riskshowService.countRiskshowByStaffIdMonth(map));
        statisticsResult.setPriceAll(riskshowService.sumPriceByStaffIdAll(map));
        statisticsResult.setPriceMonth(riskshowService.sumPriceByStaffIdMonth(map));
        return statisticsResult;
    }

    @ApiOperation(value = "个人兑换数据统计" , notes = "")
    @PostMapping("/countConversionByStaff")
    public ConversionResult countConversionByStaff(@RequestBody Map map){
        ConversionResult conversionResult = new ConversionResult();
        conversionResult.setConversionAll(conversionSService.countConversionByStaffIdAll(map));
        conversionResult.setConversionMonth(conversionSService.countConversionByStaffIdMonth(map));
        conversionResult.setPriceAll(conversionSService.consumePriceByStaffIdAll(map));
        conversionResult.setPriceMonth(conversionSService.consumePriceByStaffIdMonth(map));
        return conversionResult;
    }
}
